<?php

namespace Sharks\Core\Persistence\QueryBuilder;

use Sharks\Core\Persistence\Db;


/**
 * 完整的查询构造器
 * 使用 ezcDb https://github.com/zetacomponents/Database
 *
 * <pre>
 *      Query::createQuery()->select()->from('table')
 * </pre>
 */
class Query {

    /**
     * 执行非查询类SQL
     * @param $sql
     * @param string $identifier
     */
    public static function createRawSql($sql, $identifier = null) {
        return new RawSqlQuery($sql, $identifier);
    }

    /**
     * 执行查询类SQL
     * @param $sql
     * @param string $identifier
     * @return RawSqlSelectQuery
     */
    public static function createRawSqlSelect($sql, $identifier = null) {
        return new RawSqlSelectQuery($sql, $identifier);
    }

    /**
     * 执行 Select Query Builder
     * @param string $identifier
     * @return SelectQuery
     */
    public static function createSelect($identifier = null) {
        return new SelectQuery($identifier);
    }

    /**
     * 执行 Update Query Builder
     * @param string $identifier
     * @return UpdateQuery
     */
    public static function createUpdate($identifier = null) {
        return new UpdateQuery($identifier);
    }

    /**
     * 执行 Delete Query Builder
     * @param string $identifier
     * @return DeleteQuery
     */
    public static function createDelete($identifier = null) {
        return new DeleteQuery($identifier);
    }

    /**
     * 执行 Insert Query Builder
     * @param null $identifier
     * @return InsertQuery
     */
    public static function createInsert($identifier = null) {
        return new InsertQuery($identifier);
    }

}